
<?php if ( $_SESSION['logged_in'] == FALSE ) redirect (base_url ()); ?>
<script>
var area = "<?php echo $area; ?>";
var action = "<?php echo $action; ?>";
//alert(filt);

$(function() {
           var theme = getDemoTheme();
           // var url = "jqgetreg?action="+action+"&area="+area;
           var url = "/index.php/jqgetreg";
           
            // prepare the data
            var source =
            {
                datatype: "json",
                datafields: [
                    { name: 'Name' },
                    { name: 'username' },
                    { name: 'mobile'},
                    { name: 'address' },
                    { name: 'emailvrified' },
                    { name: 'status' }
                ],
                id: 'username',
                url: url,
                root: 'data'
            };
            
            
            var dataAdapter = new $.jqx.dataAdapter(source);

            $("#jqxgrid").jqxGrid(
            {
                width: 900,
                source: dataAdapter,
                theme: theme,
                columnsresize: true,
                pageable: true,
                columns: [
                  { text: 'Name', dataField: 'Name', width: 100 },
                  { text: 'Email', dataField: 'username', width: 200 },
                  { text: 'Mobile', dataField: 'mobile', width: 150 },
                  { text: 'Address', dataField: 'address', width: 300, cellsalign: 'left' },
                  { text: 'Verified', dataField: 'emailvrified', width: 75, cellsalign: 'center' },
                  { text: 'Status', dataField: 'status', width: 75, cellsalign: 'center' }
                ]
            });
            
            $("#jqxgrid").jqxGrid('enablehover', true);

            // display selected row index.
            $("#jqxgrid").on('rowselect', function (event) {
               // $("#selectrowindex").text(event.args.rowindex);
                var rowindex = event.args.rowindex;
                var datarow = $("#jqxgrid").jqxGrid('getrowdata', rowindex);
                var emailaddress = datarow['username'];
                //   window.location.replace("../manregbyemail?em="+emailaddress);
                post_to_url("../manregbyemail", {'username' : emailaddress} , 'post')
            });
});

function post_to_url(path, params, method) {
    method = method || "post"; // Set method to post by default, if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        if(params.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
              hiddenField.setAttribute("name", key);
              hiddenField.setAttribute("value", params[key]);
              //  hiddenField.setAttribute("name", 'username');
              //  hiddenField.setAttribute("value", params);

            form.appendChild(hiddenField);
         }
    }
    document.body.appendChild(form);
    form.submit();
}
</script>


<?php

/*
 * This lists the registrations in a grid
 * on clicking the row the user is taken to moderatereg.php
 * to moderate the user
 */


?>
<div id='jqxWidget1' style="font-size: 13px; font-family: Verdana; float: left;">
        <div id="jqxgrid">
        </div>
        <div id="eventslog" style="display: none; margin-top: 30px;">
            <div style="float: left;">
                
                <div style="border: none;" id="events">
                </div>
            </div>
            <div style="float: left;">
                Paging Details:
                <div id="paginginfo">
                </div>
            </div>
        </div>
    </div>
<!--<div style="margin-top: 10px;">
            <span>Selected Row Index:</span> <span id="selectrowindex"></span>
            <br />
            <span>Selected Email Address</span> <span id="uname"></span>
            <br />
            <span>Unselected Row Index:</span> <span id="unselectrowindex"></span>
</div>-->


